{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "from math import pi\n",
    "from matplotlib import pyplot as plt\n",
    "\n",
    "class Vehicle:\n",
    "    def __init__(self):\n",
    "        self.x       = 0 # meters\n",
    "        self.y       = 0\n",
    "        self.heading = \"E\" # Can be \"N\", \"S\", \"E\", or \"W\"\n",
    "        self.history = []\n",
    "        \n",
    "    def drive_forward(self, displacement):\n",
    "        \"\"\"\n",
    "        Updates x and y coordinates of vehicle based on \n",
    "        heading and appends previous (x,y) position to\n",
    "        history.\n",
    "        \"\"\"\n",
    "        \n",
    "        # east\n",
    "        if self.heading == \"E\":\n",
    "            delta_x = displacement \n",
    "            delta_y = 0\n",
    "        \n",
    "        # north\n",
    "        elif self.heading == \"N\":\n",
    "            delta_x = 0 \n",
    "            delta_y = displacement\n",
    "        \n",
    "        # west\n",
    "        elif self.heading == \"W\":\n",
    "            delta_x = -displacement\n",
    "            delta_y = 0\n",
    "        \n",
    "        # south\n",
    "        else:\n",
    "            delta_x = 0 \n",
    "            delta_y = -displacement\n",
    "            \n",
    "        new_x = self.x + delta_x\n",
    "        new_y = self.y + delta_y\n",
    "        \n",
    "        self.history.append((self.x, self.y))\n",
    "\n",
    "        self.x = new_x\n",
    "        self.y = new_y\n",
    "        \n",
    "    def turn(self, direction):\n",
    "        if direction == \"L\":\n",
    "            self.turn_left()\n",
    "        elif direction == \"R\":\n",
    "            self.turn_right()\n",
    "        else:\n",
    "            print(\"Error. Direction must be 'L' or 'R'\")\n",
    "            return\n",
    "        \n",
    "    def turn_left(self):\n",
    "        next_heading = {\n",
    "            \"N\" : \"W\",\n",
    "            \"W\" : \"S\",\n",
    "            \"S\" : \"E\",\n",
    "            \"E\" : \"N\",\n",
    "        }\n",
    "        self.heading = next_heading[self.heading]\n",
    "        \n",
    "    def turn_right(self):\n",
    "        next_heading = {\n",
    "            \"N\" : \"E\",\n",
    "            \"W\" : \"N\",\n",
    "            \"S\" : \"W\",\n",
    "            \"E\" : \"S\",\n",
    "        }\n",
    "        self.heading = next_heading[self.heading]\n",
    "    \n",
    "    def show_trajectory(self):\n",
    "        \"\"\"\n",
    "        Creates a scatter plot of vehicle's trajectory.\n",
    "        \"\"\"\n",
    "        X = [p[0] for p in self.history]\n",
    "        Y = [p[1] for p in self.history]\n",
    "        \n",
    "        X.append(self.x)\n",
    "        Y.append(self.y)\n",
    "        \n",
    "        plt.scatter(X,Y)\n",
    "        plt.plot(X,Y)\n",
    "        plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAW4AAAD8CAYAAABXe05zAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAEJBJREFUeJzt3XFsnPV9x/HPp447Dgq6SbAKH7AwabJWFa2uTqyZpWorXU1bRC3+gqn9Y5qU/NFNsE2O6v5T7Y+JSJ4q/pmmWcDKVJqGGWNVjNUguYghrUkdjsWw4KkD6ubMFiN0A6bTYi7f/XHnJDbn+Bzu8XM/+/2SothPHnxfzs+9efK7xzyOCAEA0vGxvAcAAGwP4QaAxBBuAEgM4QaAxBBuAEgM4QaAxBBuAEgM4QaAxBBuAEjMviy+6PXXXx/79+/P4ksDwK508uTJtyPihk72zSTc+/fv1/z8fBZfGgB2Jdu/6HRflkoAIDGEGwASQ7gBIDGEGwASQ7gBIDEdXVVi+01J70lqSPogIspZDgUA2Nx2Lgf8/Yh4O7NJsCvMVKqamF3Ucq2ugWJBYyODGh0q5T0WkKmdPu4zuY4be9NMparx6QXVVxuSpGqtrvHpBUki3ti18jjuOw13SHrWdkj6u4iYzGQaJG1idvHCwbumvtrQ4alTOnpiKaepgGxVlmo61zi/blt9ta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eUf7EvskFWzvk3S1unyXsI16Kdwd3ZQYH2Z7v6QhScfznaSptSTxsqSzkp6LiF6Y6yFJhyX14h2oQ9Kztk/aPpj3MJJ+Q9KKpL9vLS09bPuavIfa4F5JR/MeQpIioirpryUtSXpL0v9ExLNZPmYvhbujmxJjPdufkPSkpAci4t2855GkiGhExGfUvD/p7bZzXWKyfZeksxFxMs85LmM4Ij4r6cuSvtlansvTPkmflfS3ETEk6X8l9cR7TpLUWrq5W9I/5j2LJNn+VTVXB26VNCDpGttfz/Ixeyncmd+UeLdprSE/KenxiJjOe56NWn+9fl7SnTmPMizp7tZa8g8lfcH29/Md6aKIWG79flbSU2ouG+bpjKQzl/xNaUrNkPeKL0t6KSL+O+9BWr4o6Y2IWImIVUnTkn43ywfspXBfuClx67+o90r6Uc4z9azWm4CPSDodEd/Ne541tm+wXWx9XFDzoH4tz5kiYjwiboqI/WoeV3MRkekZUadsX9N6c1mt5YgvScr1CqaI+C9Jv7S9dpvyOyTl+qb3BvepR5ZJWpYkfc721a3X5R1qvueUmY7uObkTIuID238iaVYXb0r8as5jyfZRSb8n6XrbZyR9JyIeyXcqSc2zyG9IWmitJ0vSt1v3B83TjZIea73r/zFJT0RET11+12M+Kemp5utd+yT9ICJ+nO9IkqQ/lfR46yTqdUl/lPM8kiTbV6t55dmhvGdZExHHbU9JeknSB5IqyvgnKHvmckAAQGd6aakEANABwg0AiSHcAJAYwg0AiSHcAJAYwg0AiSHcAJAYwg0Aifl/Fm9jln2VIt4AAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Nice job! Your vehicle is behaving as expected!\n"
     ]
    }
   ],
   "source": [
    "# TESTING CODE 1\n",
    "\n",
    "# instantiate vehicle\n",
    "v = Vehicle()\n",
    "\n",
    "# drive in spirals of decreasing size\n",
    "v.drive_forward(8)\n",
    "v.turn(\"L\")\n",
    "\n",
    "v.drive_forward(5)\n",
    "v.turn(\"L\")\n",
    "\n",
    "v.drive_forward(5)\n",
    "v.turn(\"L\")\n",
    "\n",
    "v.drive_forward(4)\n",
    "v.turn(\"L\")\n",
    "\n",
    "v.drive_forward(4)\n",
    "v.turn(\"L\")\n",
    "\n",
    "v.drive_forward(3)\n",
    "v.turn(\"L\")\n",
    "\n",
    "v.drive_forward(3)\n",
    "v.turn(\"L\")\n",
    "\n",
    "v.drive_forward(2)\n",
    "v.turn(\"L\")\n",
    "\n",
    "v.drive_forward(2)\n",
    "v.turn(\"L\")\n",
    "\n",
    "v.drive_forward(1)\n",
    "v.turn(\"L\")\n",
    "\n",
    "v.drive_forward(1)\n",
    "\n",
    "# show the trajectory. It should look like a spiral\n",
    "v.show_trajectory()\n",
    "\n",
    "# TESTING\n",
    "assert(v.x == 5)\n",
    "assert(v.y == 3)\n",
    "first_5 = [\n",
    "    (0, 0),\n",
    "    (8, 0),\n",
    "    (8, 5),\n",
    "    (3, 5),\n",
    "    (3, 1)\n",
    "]\n",
    "assert(first_5 == v.history[:5])\n",
    "print(\"Nice job! Your vehicle is behaving as expected!\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXwAAAD8CAYAAAB0IB+mAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAADzhJREFUeJzt3V+IXOd5x/Hfrxvii1JohNTYtbxdVSgXcl1EOzgWoiGlolGSUtkBg4xdDClSAvZ9JRxoLgw1aUMoNE2zKiYBq3ZNg2wRiThWLhowlpMVdWzJqVvJUeSNRKxUF71ocbHy9EIz65V2dvfMnDn/5vl+YNHMmT/v62H007Ovz3seR4QAANPvV5qeAACgH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bb32H7T9jnbB5ueT1vYvmD79f53I+UV92w/afsd22eWHdtg+0Xb/9n/80NNzrFuq3wmZElfawO/7ysRsaP/c6LpydTN9oykr0r6pKTtkh6wvb3ZWbXKH/a/G1lPufuGpD03HTso6XsRsU3S9/r3M/mGVn4mUvIsGWh74Gd3t6RzEfFWRPyfpGck7W14TmiJiPi+pJubu+6V9M3+7W9KurfWSTVslc8EfW0P/Edtv9b/NS3Vr6Z9t0ta3jF6sX8MUkj6ru3Ttg80PZkW+XBEXJak/p+/0fB82iJ7lkhqOPBtn7R9ZsjPXklfk7RV0g5JlyV9ucm5NsRDjnFa1XW7IuL3dH256xHbH2t6QmgtsqSv0SbmEbG7yPNsH5b07Yqn00aLkpY3Ct0s6VJDc2mViLjU//Md20d1ffnr+83OqhV+bvu2iLhs+zZJ7zQ9oaZFxM8HtxNniaQWL+n0v6wD90k6s9pzp9gPJW2zvcX2ByXtk3Ss4Tk1zvav2v61wW1Jf6yc349hjkl6uH/7YUnPNziXViBL3tdohb+OL9neoetLGBckfa7Z6dQvIt6z/aikFyTNSHoyIs42PK02+LCko77eRPsDkv4pIr7T7JTqZ/tpSR+XtNH2oqS/lPSEpGdt/7mki5Lub26G9VvlM/l49iwZYKctACTR2iUdAMBkEfgAkASBDwBJEPgAkASBDwBJEPgAkASBDwBJEPgAkMT/A2BH/3NK89cxAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Nice job! Your vehicle passed the zig zag test.\n"
     ]
    }
   ],
   "source": [
    "# TESTING CODE Part 2\n",
    "def test_zig_zag():\n",
    "    v = Vehicle()\n",
    "    for i in range(10):\n",
    "        for _ in range(4):\n",
    "            v.drive_forward(2)\n",
    "            v.turn(\"R\")\n",
    "            v.drive_forward(1)\n",
    "            v.turn(\"L\")\n",
    "        v.drive_forward(10)\n",
    "        v.turn(\"R\")\n",
    "    first_six = [\n",
    "        (0,0),\n",
    "        (2,0),\n",
    "        (2,-1),\n",
    "        (4,-1),\n",
    "        (4,-2),\n",
    "        (6,-2)\n",
    "    ]\n",
    "    v.show_trajectory()\n",
    "    assert(v.x == 14)\n",
    "    assert(v.y == -22)\n",
    "    assert(v.history[:6] == first_six)\n",
    "    print(\"Nice job! Your vehicle passed the zig zag test.\")\n",
    "test_zig_zag()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
